package com.yc.demo2.web;

import com.yc.demo2.dto.Person;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.logging.Logger;

/**
 * @author navy
 * @company 源辰信息
 * @date 2024/9/8
 * @email haijunzhou@hnit.edu.cn
 */
@RestController
@Slf4j // 自动生成 log 对象
public class DemoAction {

    @RequestMapping("hello")
    String hello(){
        return "hello springboot";
    }

    // ${} 读取配置文件数据
    @Value("${demo.name}")
    String myname;

    @RequestMapping("myname")
    String getMyname(){
        return myname;
    }

    @Autowired
    Person person;

    @RequestMapping("myPerson")
    Person myPerson(){
        return person;
    }

    @RequestMapping("log")
    String log(){
        this.log.debug("-------debug------");
        this.log.info("-------info------");
        this.log.warn("-------warn------");
        this.log.error("-------error------");
        return "log";
    }
}
